<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>角色修改</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
<link href="/hmp/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/hmp/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="/hmp/css/animate.css" rel="stylesheet">
<link href="/hmp/css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="signupForm">
							<input id="pid" name="pid" type="hidden"
								value="${roleDo.pid!''}" /> <input id="id" name="id"
								type="hidden" value="${roleDo.id}" />
							<div class="form-group">
								<label class="col-sm-3 control-label">上级角色：</label>
								<div class="col-sm-8">
									<input id="pName" name="pName" class="form-control" type="text"
										value="${pName!''}" readonly >
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">角色名称：</label>
								<div class="col-sm-8">
									<input id="name" name="name" class="form-control" type="text"
										value="${roleDo.name!''}" required>
								</div>
							</div>
						 <div class="form-group">
								<label class="col-sm-3 control-label">角色状态：</label>
								<div class="col-sm-8">
									 <label class="radio-inline"> <input type="radio"<#if
										(roleDo.state == 1)> checked </#if> name="state" value="1" /> 启用
									</label> <label class="radio-inline"> <input type="radio"<#if
										(roleDo.state == 0)> checked </#if> name="state" value="0" /> 停用
									</label>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">排序：</label>
								<div class="col-sm-8">
									<input id="sort" name="sort" class="form-control" type="text"
										value="${roleDo.sort!''}">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">备注：</label>
								<div class="col-sm-8">
									<input id="remarks" name="remarks" class="form-control"
										type="text" value="${roleDo.remarks!''}">
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-8 col-sm-offset-3">
									<button type="submit" class="btn btn-info">提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="/hmp/js/jquery.min.js"></script>
<script src="/hmp/js/bootstrap.min.js"></script>
<script src="/hmp/layui/layui/layui.js"></script>
<!-- jQuery Validation plugin javascript-->
<script src="/hmp/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/hmp/js/plugins/validate/messages_zh.min.js"></script>

<script type="text/javascript">
$(function(){
	
validateRule();
//全局layui 定义  
layui.use('layer', function() {
	var layer = layui.layer;
	//打开图标列表
	   $("#ico-btn").click(function(){
	       layer.open({
	           type: 2,
			   title:'图标列表',
	           content: '/FontIcoList.html',   //一直是放在public下面 直接 访问到了 
	           area: ['480px', '90%'],
	           success: function(layero, index){
	               //var body = layer.getChildFrame('.ico-list', index);
	               //console.log(layero, index);
	           }
	       });
	   });
	}); 

});


$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});


function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			name : {
				required : true
			} 
		},
		messages : {
			name : {
				required : icon + "请输入角色名"
			} 
		}
	})
}


function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url :  "/role/update",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		dataType: "json",
		error : function(request) {
			parent.laryer.alert("网络错误");
		},
		success : function(data) {
			if (data.code == 200) {
				parent.layer.msg(data.msg);
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});
}
</script>
</html>
